package main

import "fmt"

type ClassMate struct {
	Name    string
	Age     int
	Address string
}

// 不能修改结构体中的 成员变量
func (c ClassMate) printAndModifyName() {
	c.Name = "clc"
	fmt.Println(c.Name)
}

// 可以修改 classMate中的 成员变量
func (c *ClassMate) SetName(name string) {
	c.Name = name
}

func main() {

	c := ClassMate{}
	c.Address = "南京"
	c.Name = "WuSir"
	c.Age = 1561321

	fmt.Printf("name: %s , age:%d, address:%s\n", c.Name, c.Age, c.Address)

	c1 := ClassMate{Name: "alen", Age: 2352, Address: "北京"}
	fmt.Println(c1)

	fmt.Printf("name: %s , age:%d, address:%s\n", c1.Name, c1.Age, c1.Address)

	c1.printAndModifyName()
	fmt.Printf("name: %s , age:%d, address:%s\n", c1.Name, c1.Age, c1.Address)

	c1.SetName("alex")
	fmt.Printf("name: %s , age:%d, address:%s\n", c1.Name, c1.Age, c1.Address)
}
